/**
 * @Author ZhangCuirong
 * @Date 2025/8/28 15:14
 * @description:
 */
public class Solution26 {
    public int removeDuplicates(int[] nums) {
        int slow = 0, fast = 0;
        while (fast < nums.length) {
            if (nums[slow] == nums[fast]) {
                fast++;
            } else {
                slow++;
                nums[slow] = nums[fast++];
            }
        }
        return slow + 1;
    }

    public static void main(String[] args) {
        Solution26 solution = new Solution26();
        System.out.println(solution.removeDuplicates(new int[]{1, 1, 2}));
        System.out.println(solution.removeDuplicates(new int[]{0, 0, 1, 1, 1, 2, 2, 3, 3, 4}));
    }
}
